#include<bits/stdc++.h>
using namespace std ;
int n , m , L , V ;
int d[100005] , v[100005] , a[100005] , l[100005] ;
vector<pair<int , int> > ve ;
void solve(){
    ve.clear() ;
    int cnt = 0 ;
    cin >> n >> m >> L >> V ;
    for(int i = 1 ; i <= n ; i++) cin >> d[i] >> v[i] >> a[i] ;
    for(int i = 1 ; i <= m ; i++) cin >> l[i] ;
    for(int i = 1 ; i <= n ; i++){
        if(a[i] > 0){
            double ex_p = (double)(V * V - v[i] * v[i]) / (double)(2 * a[i]) + d[i] ;
            int p = upper_bound(l + 1 , l + m + 1 , ex_p) - l ;
            if(p == m + 1) continue ;
            //if(l[p] - ex_p < 0.03) cout << fixed << setprecision(5) << ex_p << ' ' << l[p] << "\n";
            //if((l[p] - d[i]) < (v[i] + 2 * a[i] * (l[p] - d[i])) * (v[i] + 2 * a[i] * (l[p] - d[i]))) continue ;
            cnt++ ;
            ve.push_back(make_pair(p , m)) ;
        }
        else if(a[i] == 0){
            if(v[i] <= V || d[i] > l[m]) continue ;
            int p = lower_bound(l + 1 , l + m + 1 , d[i]) - l ;
            cnt++ ;
            ve.push_back(make_pair(p , m)) ;
        }
        else{
            if(v[i] <= V || d[i] > l[m]) continue ;
            double ex_p = (double)(V * V - v[i] * v[i]) / (double)(2 * a[i]) + d[i] ;
            int p = lower_bound(l + 1 , l + m + 1 , ex_p) - l ;
            int p2 = lower_bound(l + 1 , l + m + 1 , d[i]) - l ;
            if(p2 == m + 1) continue ;
            p -= 1 ;
            if(p < p2) continue ;
            cnt++ ;
            ve.push_back(make_pair(p2 , p)) ;
        }
    }
    cout << cnt << ' ' ;
    cnt = 0 ;
    int sz = ve.size() ;
    sort(ve.begin() , ve.end()) ;
    for(int i = 0 ; i < sz ; i++){
        cnt++ ;
        //cout << ve[i].first << ' ' << ve[i].second << "\n" ;
        int j = i + 1 ;
        while(j < sz && ve[j].first <= ve[i].second){
            j++ ;
        }
        //cout << i << ' ' << j ;
        i = j - 1 ;
    }
    cout << m - cnt << "\n" ;
}
int main(){
    cin.tie(0) ;cout.tie(0) ;
    ios::sync_with_stdio(0) ;
    freopen("detect.in","r",stdin) ;
    freopen("detect.out","w",stdout) ;
    int t ;
    cin >> t ;
    while(t--) solve() ;
    return 0 ;
}
